<html>
<head><meta charset="utf-8"><title>polonius debugging · t-compiler/wg-nll · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/index.html">t-compiler/wg-nll</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html">polonius debugging</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="134775716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134775716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134775716">(Sep 27 2018 at 21:47)</a>:</h4>
<p><span class="user-mention" data-user-id="116113">@lqd</span> if you were inclined to do some polonius hacking... one thing I would like is to improve the debugging output</p>



<a name="134775723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134775723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134775723">(Sep 27 2018 at 21:47)</a>:</h4>
<p>e.g., for this test failure, I get</p>



<a name="134775724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134775724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134775724">(Sep 27 2018 at 21:47)</a>:</h4>
<div class="codehilite"><pre><span></span>  left: `{Point { index: 1 }: [Loan { index: 0 }]}`,
 right: `{}`&#39;, src/test.rs:186:5
</pre></div>



<a name="134775726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134775726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134775726">(Sep 27 2018 at 21:47)</a>:</h4>
<p>but what I would like to see is <code>Point { index: 1 }</code> written as <code>mid(BB1)</code> or whatever</p>



<a name="134775728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134775728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134775728">(Sep 27 2018 at 21:47)</a>:</h4>
<p>tbh I'm not entirely sure <em>which</em> point is :)</p>



<a name="134775737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134775737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134775737">(Sep 27 2018 at 21:47)</a>:</h4>
<p>I guess we could just put the "program" into thread-local data</p>



<a name="134775738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134775738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134775738">(Sep 27 2018 at 21:47)</a>:</h4>
<p>so we can access it from the Debug impl</p>



<a name="134775740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134775740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134775740">(Sep 27 2018 at 21:48)</a>:</h4>
<p>or else we can write some wrappers</p>



<a name="134775785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134775785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134775785">(Sep 27 2018 at 21:48)</a>:</h4>
<p>e.g., <code>foo.debug_in(program)</code></p>



<a name="134775789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134775789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134775789">(Sep 27 2018 at 21:48)</a>:</h4>
<p>it is quite obscure</p>



<a name="134775815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134775815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134775815">(Sep 27 2018 at 21:49)</a>:</h4>
<p>I will looking into it!</p>



<a name="134775898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134775898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134775898">(Sep 27 2018 at 21:50)</a>:</h4>
<p>(I've had the same problem before, and I go through the InternerTables to go back to the original string input: the <code>untern</code> function)</p>



<a name="134776049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776049">(Sep 27 2018 at 21:53)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> for example, in the program tests: <a href="https://github.com/rust-lang-nursery/polonius/blob/master/src/program.rs#L235-L239" target="_blank" title="https://github.com/rust-lang-nursery/polonius/blob/master/src/program.rs#L235-L239">here</a></p>



<a name="134776154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776154">(Sep 27 2018 at 21:55)</a>:</h4>
<p>I've never <em>quite</em> gotten a pattern I like</p>



<a name="134776156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776156">(Sep 27 2018 at 21:55)</a>:</h4>
<p>I think in my ideal world</p>



<a name="134776158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776158">(Sep 27 2018 at 21:55)</a>:</h4>
<p>we'd have a <code>DebugWith</code> trait</p>



<a name="134776159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776159">(Sep 27 2018 at 21:55)</a>:</h4>
<p>and a derive for it</p>



<a name="134776199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776199">(Sep 27 2018 at 21:56)</a>:</h4>
<p>which takes some context as argument</p>



<a name="134776203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776203">(Sep 27 2018 at 21:56)</a>:</h4>
<p>i.e., the types would not implement <code>Debug</code></p>



<a name="134776204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776204">(Sep 27 2018 at 21:56)</a>:</h4>
<p>but <code>DebugWith</code></p>



<a name="134776206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776206">(Sep 27 2018 at 21:56)</a>:</h4>
<p>and then you would do <code>format!("{:?}", foo.debug_with(&amp;interner))</code> or whatever</p>



<a name="134776211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776211">(Sep 27 2018 at 21:56)</a>:</h4>
<p>where <code>debug_with</code> would return some wrapper that implements <code>Debug</code></p>



<a name="134776215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776215">(Sep 27 2018 at 21:57)</a>:</h4>
<p>but I've never tried this pattern out at scale to see how it feels :)</p>



<a name="134776223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776223">(Sep 27 2018 at 21:57)</a>:</h4>
<p>mostly because usually i am too busy trying to get something done</p>



<a name="134776226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776226">(Sep 27 2018 at 21:57)</a>:</h4>
<p>..kind of like right now</p>



<a name="134776244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776244">(Sep 27 2018 at 21:57)</a>:</h4>
<p>maybe we can try it in polonius (it wouldn't be that big of a scale)</p>



<a name="134776298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776298">(Sep 27 2018 at 21:58)</a>:</h4>
<p>I also need to learn how to write a custom derive</p>



<a name="134776300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776300">(Sep 27 2018 at 21:58)</a>:</h4>
<p>I was searching for that recently and found it surprisingly ill-documented</p>



<a name="134776312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776312">(Sep 27 2018 at 21:59)</a>:</h4>
<p>presumably <code>syn</code> or something makes it easy :)</p>



<a name="134776316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776316">(Sep 27 2018 at 21:59)</a>:</h4>
<p>I've always wanted a "meta-derive", where you can annotate traits with the derive pattern you want, and it will generate the derive for you...</p>



<a name="134776325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776325">(Sep 27 2018 at 21:59)</a>:</h4>
<p>..since for me at least it's usually one of a few options...</p>



<a name="134776327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776327">(Sep 27 2018 at 21:59)</a>:</h4>
<p>/me rambles</p>



<a name="134776329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776329">(Sep 27 2018 at 22:00)</a>:</h4>
<p>ok, I gotta run</p>



<a name="134776404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776404">(Sep 27 2018 at 22:00)</a>:</h4>
<p>dtolnay has interesting tests/accessory crates helping out, as always :)</p>



<a name="134776594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/polonius%20debugging/near/134776594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/polonius.20debugging.html#134776594">(Sep 27 2018 at 22:05)</a>:</h4>
<p>(and of course the example in <a href="https://github.com/dtolnay/reflect" target="_blank" title="https://github.com/dtolnay/reflect">reflect</a> is for a Debug custom derive <span class="emoji emoji-1f602" title="joy">:joy:</span> )</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>